package com.tools.developer.app;

import java.util.ArrayList;

import android.app.Service;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.tools.developer.R;

public class AppCatalogAdapter extends BaseAdapter {
	private Context mCtx;
	public ArrayList<String> mTitles;

	public AppCatalogAdapter(Context context) {
		mCtx = context;
		mTitles = new ArrayList<String>();
		mTitles.add(mCtx.getString(R.string.app_catalog_all));
		mTitles.add(mCtx.getString(R.string.app_catalog_debug));
		mTitles.add(mCtx.getString(R.string.app_catalog_running));
		mTitles.add(mCtx.getString(R.string.app_catalog_service));
		mTitles.add(mCtx.getString(R.string.app_catalog_sys_app));
		mTitles.add(mCtx.getString(R.string.app_catalog_letter));
		mTitles.add(mCtx.getString(R.string.app_catalog_storage));
		mTitles.add(mCtx.getString(R.string.app_catalog_sd));
		mTitles.add(mCtx.getString(R.string.app_catalog_time));
	}

	@Override
	public int getCount() {
		return mTitles.size();
	}

	@Override
	public Object getItem(int position) {
		return mTitles.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			LayoutInflater inflater = (LayoutInflater) mCtx
					.getSystemService(Service.LAYOUT_INFLATER_SERVICE);
			convertView = inflater
					.inflate(R.layout.app_catalog_list_item, null);
			holder.catalogTitle = (TextView) convertView
					.findViewById(R.id.app_catalog_item_title);

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.catalogTitle.setText(mTitles.get(position));
		return convertView;
	}

	class ViewHolder {
		TextView catalogTitle;
	}

}
